using System.Collections;
using System.Collections.Generic;
using UnityEngine;

// 判断一个物体B位置再另一个物体A的位置的左上，左下，右上,右下哪个方位
public class Lesson3_exercise1 : MonoBehaviour
{
    public Transform A;
    public Transform B;
    // Update is called once per frame
    void Update()
    {
        //判断左右
        Vector3 relativeDir = B.position - A.position;
        Vector3 c1 = Vector3.Cross(A.forward, relativeDir);
        //判断前后
        if (Vector3.Dot(A.forward, B.position - A.position) > 0)
        {
            if (c1.y >= 0)
                Debug.LogFormat("右前");
            else
                Debug.LogFormat("左前");
        }
        else
        {
            if (c1.y >= 0)
                Debug.LogFormat("右后");
            else
                Debug.LogFormat("左后");
        }
    }
}
